<template>
  <div class="page">
  </div>
</template>
<script>
  import { mapGetters } from 'vuex'
  const config = require('~src/config')
  const util = require('~src/lib/util')
  export default {
    name: 'index',
    data () {
      return {
      }
    },
    computed: {
      ...mapGetters({
        getOpenid: 'globla/getOpenid'
      })
    },
    mounted () {
      var _this = this
        var openid = util.localItem.get('openid')
        var code = _this.$route.query.code
        _this.$store.dispatch('TOAST_SHOW', {autoClose: false, toast: true, loading: true})
        // 如果本地没有openId
        if (util.isEmptyObject(openid)) {
          // 如果地址栏返回地址有code就直接拿code去获取openId,反之去跳微信认证
          if (!util.isEmptyObject(code)) {
            // 用获取的code去得到openId
            _this.$store.dispatch('globla/getOpenid', code)
          }else{
            var href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2d698f87cf0e85c9&redirect_uri=http%3A%2F%2Fwww.carutoo.com%2FHome%2FIndex%2FwechatOauth%3Frurl%3Dhttp%3A%2F%2F'+config._WXURL_+'%2F%26__lion_from_weixin%3Dyes&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect'
            location.href = href
          }
        } else {
          location.href = '/vip'
        }
    },

    methods: {
    }
  }
</script>
<style lang="scss">
  .iframe{
    opacity: 1;
  }
</style>
